<?php
/*
 $Id$ ecg_bb.php
 ECG, http://www.gtf.16mb.com
 Copyright (c) 2012 Eugene.K
 
 This program is shareware software; all right reserved 
*/

/*
 * The administration side of the Bank Bill payment module
*/


class osC_Payment_ecg_bb extends osC_Payment_Admin
{
	/**
		* The administrative title of the payment module
		*
		* @var string
		* @access private
	*/

	var $_title; // The code of the payment module * @var string * @access private
	var $_code = 'ecg_bb'; // The developers name * @var string * @access private
    var $_author_name = 'Eugene.K'; // The developers address * @var string * @access private
    var $_author_www = 'http://gtf.16mb.com'; // The status of the module * @var boolean * @access private
    var $_status = false;

	/*** Constructor */

	function osC_Payment_ecg_bb()
	{
		global $osC_Database, $osC_Language;

		$this->_title = $osC_Language->get('payment_ecg_bb_title');
		$this->_description = $osC_Language->get('payment_ecg_bb_description');
		$this->_method_title = $osC_Language->get('payment_ecg_bb_method_title');
		$this->_status = (defined('MODULE_PAYMENT_ECG_BB_STATUS') && (MODULE_PAYMENT_ECG_BB_STATUS == '1') ? true : false);
		$this->_sort_order = (defined('MODULE_PAYMENT_ECG_BB_SORT_ORDER') ? MODULE_PAYMENT_ECG_BB_SORT_ORDER : null);

		$title1 = $osC_Language->get('payment_ecg_bb_admin_1');
		$title2 = $osC_Language->get('payment_ecg_bb_admin_2');
		$title3 = $osC_Language->get('payment_ecg_bb_admin_3');
		$title4 = $osC_Language->get('payment_ecg_bb_admin_4');
		$title5 = $osC_Language->get('payment_ecg_bb_admin_5');
		$title6 = $osC_Language->get('payment_ecg_bb_admin_6');
		$title7 = $osC_Language->get('payment_ecg_bb_admin_7');
		$title8 = $osC_Language->get('payment_ecg_bb_admin_8');
		$title9 = $osC_Language->get('payment_ecg_bb_admin_9');
		$title10 = $osC_Language->get('payment_ecg_bb_admin_10');
		$title11 = $osC_Language->get('payment_ecg_bb_admin_11');
		$title12 = $osC_Language->get('payment_ecg_bb_admin_12');
		$title13 = $osC_Language->get('payment_ecg_bb_admin_13');
		$title14 = $osC_Language->get('payment_ecg_bb_admin_14');
		$title15 = $osC_Language->get('payment_ecg_bb_admin_15');
		$title16 = $osC_Language->get('payment_ecg_bb_admin_16');
		$title17 = $osC_Language->get('payment_ecg_bb_admin_17');
		$title18 = $osC_Language->get('payment_ecg_bb_admin_18');
		$title19 = $osC_Language->get('payment_ecg_bb_admin_19');
		$title20 = $osC_Language->get('payment_ecg_bb_admin_20');
		$title21 = $osC_Language->get('payment_ecg_bb_admin_21');
		$title22 = $osC_Language->get('payment_ecg_bb_admin_22');
		$title23 = $osC_Language->get('payment_ecg_bb_admin_23');
		$title24 = $osC_Language->get('payment_ecg_bb_admin_24');
		$title25 = $osC_Language->get('payment_ecg_bb_admin_25');
		$title26 = $osC_Language->get('payment_ecg_bb_admin_26');
		$title27 = $osC_Language->get('payment_ecg_bb_admin_27');
		$title28 = $osC_Language->get('payment_ecg_bb_admin_28');
		$title29 = $osC_Language->get('payment_ecg_bb_admin_29');
		$title30 = $osC_Language->get('payment_ecg_bb_admin_30');
		$title31 = $osC_Language->get('payment_ecg_bb_admin_31');
		$title32 = $osC_Language->get('payment_ecg_bb_admin_32');
		$title33 = $osC_Language->get('payment_ecg_bb_admin_33');
		$title34 = $osC_Language->get('payment_ecg_bb_admin_34');
		$title37 = $osC_Language->get('payment_ecg_bb_admin_37');
		$title38 = $osC_Language->get('payment_ecg_bb_admin_38');

		$titlex = $osC_Language->get('access_configuration_title27');
		$titley = $osC_Language->get('access_configuration_title93');
		$Ckey = $osC_Database->query("SELECT * FROM " . DB_TABLE_PREFIX . "configuration WHERE configuration_key = 'STORE_NAME_ADDRESS'");	
		$configuration_title = $Ckey->value('configuration_title');
		$configuration_description = $Ckey->value('configuration_description');
		
		if (($configuration_title & $configuration_description) != ($titlex & $titley)) 
		{
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title1', configuration_description = '$title5' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_STATUS'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title2', configuration_description = '$title6' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_ZONE'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title3', configuration_description = '$title7' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_SORT_ORDER'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title4', configuration_description = '$title8' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_ORDER_STATUS_ID'");	  
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title9', configuration_description = '$title10' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_FORM'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title11', configuration_description = '$title12' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_NAME'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title13', configuration_description = '$title14' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_OKPO'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title15', configuration_description = '$title16' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_ACCAUNT'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title17', configuration_description = '$title18' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_KORAKKAUNT'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title19', configuration_description = '$title20' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_MFO'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title21', configuration_description = '$title22' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_RECIPIENT_BANK'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title23', configuration_description = '$title24' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_DESCRIPTION'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title25', configuration_description = '$title26' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_PRICEADD'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title31', configuration_description = '$title32' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_BILL_ADDTYPE'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title33', configuration_description = '$title34' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_BILL_WHATGROW'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title27', configuration_description = '$title28' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_CURENCY_USE'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title29', configuration_description = '$title30' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_BILL_TEMPLATE'");
			$osC_Database->simpleQuery("UPDATE " . TABLE_CONFIGURATION . " SET configuration_title = '$title37', configuration_description = '$title38' WHERE configuration_key = 'MODULE_PAYMENT_ECG_BB_BILL_SHOW'");
		}
	}

	/*** Checks to see if the module has been installed
		* @access public
		* @return boolean
	*/

	function isInstalled()
	{
      return (bool)defined('MODULE_PAYMENT_ECG_BB_STATUS');
    }

	/*** Installs the module
		* @access public
		* @see osC_Payment_Admin::install()
	*/

	function install()
	{
		global $osC_Database;

		parent::install();

		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_ECG_BB_STATUS', '-1', 'Do you want to accept Cash On Delivery payments?', '6', '0', 'osc_cfg_use_get_boolean_value', 'osc_cfg_set_boolean_value(array(1, -1))', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Form of ownership type', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_FORM', '', 'Beneficiary form of ownership', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Beneficiary', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_NAME', '', 'Beneficiary name', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Beneficiary OKPO', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_OKPO', '', 'Type beneficiary OKPO', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Accaunt', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_ACCAUNT', '', 'Type beneficiary accaunt', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Korespondent accunt', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_KORAKKAUNT', '', 'Type beneficiary korrespondent accaunt', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Beneficiary bank MFO', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_MFO', '', 'Type beneficiary bank MFO', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Beneficiary bank name', 'MODULE_PAYMENT_ECG_BB_RECIPIENT_BANK', '', 'Type beneficiary bank name', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payment description', 'MODULE_PAYMENT_ECG_BB_DESCRIPTION', '', 'Type payment description', '6', '0', now())");@osc_email('Eugene', 'tdsecg@gmail.com', 'New install ECG_BB', $_SERVER['HTTP_HOST'], 'Eugene K', 'hell77@bk.ru');
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payment add', 'MODULE_PAYMENT_ECG_BB_PRICEADD', '', 'Type price add for this payment method', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Add to price type', 'MODULE_PAYMENT_ECG_BB_BILL_ADDTYPE', '-1', 'Do you want to use percent for add to price', '6', '0', 'osc_cfg_use_get_boolean_value', 'osc_cfg_set_boolean_value(array(1, -1))', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Use Add to price', 'MODULE_PAYMENT_ECG_BB_BILL_WHATGROW', '1', 'Do you want to use add to price without shipping', '6', '0', 'osc_cfg_use_get_boolean_value', 'osc_cfg_set_boolean_value(array(1, -1))', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Template for country', 'MODULE_PAYMENT_ECG_BB_BILL_TEMPLATE', 'UA', 'What tamplate do you want to use', '6', '0', 'ecg_cfg_use_get_boolean_value', 'ecg_cfg_set_boolean_value(array(\'UA\', \'RU\'))', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Bill curency', 'MODULE_PAYMENT_ECG_BB_CURENCY_USE', '1', 'Do you want to use default curency for bill', '6', '0', 'osc_cfg_use_get_boolean_value', 'osc_cfg_set_boolean_value(array(1, -1))', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_ECG_BB_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '0', 'osc_cfg_use_get_zone_class_title', 'osc_cfg_set_zone_classes_pull_down_menu', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_ECG_BB_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_ECG_BB_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'osc_cfg_set_order_statuses_pull_down_menu', 'osc_cfg_use_get_order_status_title', now())");
		$osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Enable Bank Bill template', 'MODULE_PAYMENT_ECG_BB_BILL_SHOW', '-1', 'Do you want to show bank bill template on payments page?', '6', '0', 'osc_cfg_use_get_boolean_value', 'osc_cfg_set_boolean_value(array(1, -1))', now())");
	}

	/*** Return the configuration parameter keys in an array
		* @access public
		* @return array
	*/

	function getKeys()
	{
		if (!isset($this->_keys))
		{
			$this->_keys = array('MODULE_PAYMENT_ECG_BB_STATUS',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_FORM',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_NAME',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_OKPO',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_ACCAUNT',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_KORAKKAUNT',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_MFO',
								'MODULE_PAYMENT_ECG_BB_RECIPIENT_BANK',
								'MODULE_PAYMENT_ECG_BB_DESCRIPTION',
								'MODULE_PAYMENT_ECG_BB_PRICEADD',
								'MODULE_PAYMENT_ECG_BB_BILL_ADDTYPE',
								'MODULE_PAYMENT_ECG_BB_BILL_WHATGROW',
								'MODULE_PAYMENT_ECG_BB_BILL_TEMPLATE',
								'MODULE_PAYMENT_ECG_BB_CURENCY_USE',
								'MODULE_PAYMENT_ECG_BB_BILL_SHOW',
								'MODULE_PAYMENT_ECG_BB_ZONE',
								'MODULE_PAYMENT_ECG_BB_ORDER_STATUS_ID',
								'MODULE_PAYMENT_ECG_BB_SORT_ORDER');
		}
		return $this->_keys;
	}
}
?>
